<?php
/**
 * Create by Phpstorm
 * User: Peco
 * Date: 2019/12/5
 * Time: 14:40
 */

namespace App\Http\Controllers\Api\Member;

use App\Http\Controllers\Api\BaseAdminController;
use App\Http\Requests\UserInfo\GetSmsLogPageRequest;
use App\Http\Requests\UserInfo\GetUserAddressPageRequest;
use App\Http\Requests\UserInfo\GetUserAuthenticationPageRequest;
use App\Http\Requests\UserInfo\SendUserSmsRequest;
use App\Http\Transformers\UserInfo\GetSmsLogPageTransformer;
use App\Http\Transformers\UserInfo\GetUserAddressPageTransformer;
use App\Http\Transformers\UserInfo\GetUserAuthenticationPageTransformer;
use App\Jobs\SendGroupNotification;
use App\Repositories\UserInfoRepository;

/**
 *  用户相关 包括实名认证、用户地址等
 * Class UserInfoController
 * @package App\Http\Controllers\Api\Member
 */
class UserInfoController extends BaseAdminController
{
    /**
     * @var UserInfoRepository 注入的数据模型
     */
    protected $userInfoRepository;

    /**
     * UserInfoController constructor.
     * @param UserInfoRepository $userInfoRepository
     */
    public function __construct(UserInfoRepository $userInfoRepository)
    {
        $this->userInfoRepository = $userInfoRepository;
    }

    /**
     * 认证列表分页列表
     * @param GetUserAuthenticationPageRequest $request
     * @return \Dingo\Api\Http\Response
     */
    public function getUserAuthenticationPage(GetUserAuthenticationPageRequest $request){
        $limit = $request->get('limit');
        $data = $request->all(['realname', 'real_status', 'userId']);
        $banner = $this->userInfoRepository->getUserAuthenticationPageRepository($data, $limit);

        return $this->response->paginator($banner, new GetUserAuthenticationPageTransformer());
    }

    /**
     * 获取用户地址列表
     * @param GetUserAddressPageRequest $request
     * @return \Dingo\Api\Http\Response
     */
    public function getUserAddressPage(GetUserAddressPageRequest $request){
        $limit = $request->get('limit');
        $data = $request->all(['mobile', 'consignee', 'userId']);
        $banner = $this->userInfoRepository->getUserAddressPageRepository($data, $limit);

        return $this->response->paginator($banner, new GetUserAddressPageTransformer());
    }

}
